﻿using System;
using UnityEngine;

namespace Yoozoo.Gameplay.City
{
    [ExecuteInEditMode]
    public class CityIndustryEditorConfig : MonoBehaviour
    {
        [Header("是否显示产业预览")]
        public bool preview = true;

        public Material material = null;
        
        private static CityIndustryEditorConfig instance;
        public static CityIndustryEditorConfig Instance
        {
            get
            {
                if (instance == null)
                {
                    instance = FindObjectOfType<CityIndustryEditorConfig>();
                }
                return instance;
            }
        }

        private Transform previewRoot;

        public Transform PreviewRoot
        {
            get
            {
                if (previewRoot == null)
                {
                    previewRoot = new GameObject("PreviewRoot").transform;
                    previewRoot.parent = this.transform;
                }

                return previewRoot;
            }
        }
        

        private void OnEnable()
        {
            GameObject.DestroyImmediate(previewRoot);
        }
    }
}